<#-- 导入模版定义文件-->
<#include "../template/template_editPage.ftl">
<@edit title="教师管理">

<body class="input">
<script type="text/javascript">
	$().ready( function() {	
		var $validateErrorContainer = $("#validateErrorContainer");
		var $validateErrorLabelContainer = $("#validateErrorContainer ul");
		var $validateForm = $("#inputForm");
		var $tab = $("#tab");
	
		// Tab效果
		$tab.tabs(".tabContent", {
			tabs: "input"
		});
		
		// 表单验证
		$validateForm.validate({
			errorContainer: $validateErrorContainer,
			errorLabelContainer: $validateErrorLabelContainer,
			wrapper: "li",
			errorClass: "validateError",
			ignoreTitle: true,
			rules: {
				"teacherInfo.teacherName": {
						required: true,
						maxlength:20
				},
				"teacherInfo.mobile": {
						required: true,
						maxlength:20
				},
				"teacherInfo.introduction": {
						maxlength:200
				}
				
			},
			messages: {
				"teacherInfo.teacherName": {
						required: "请输入教师姓名",
						maxlength: "教师姓名必须在20个字符以内"
				},
				"teacherInfo.mobile": {
						required: "请输入手机号码",
						maxlength: "手机号码必须在20个字符以内"
				},
				"teacherInfo.introduction": {
						maxlength: "教师简介必须在200个字符以内"
				}  
			},
			submitHandler: function(form) {
				$(form).find(":submit").attr("disabled", true);
				form.submit();
			}
		});
		<#if actionErrors??&&(actionErrors?size > 0)>
			$.dialog({type: "warn", content: "<#list errorMessages as list>${list}<br></#list>",
			 modal: true, autoCloseTime: 3000});
		</#if>
		<#if actionMessages??&&(actionMessages?size > 0)>
			$.dialog({type: "success", content: "<#list actionMessages as list>${list}<br></#list>",
			 modal: true, autoCloseTime: 5000});
		</#if>
    
	});
	
function showDiv(picId,imgdiv,imgShow){
   		new uploadPreview({ UpBtn: picId, DivShow: imgdiv, ImgShow: imgShow });
	}
	
	function clearImg(imgId,imgShow){
		var obj = document.getElementById(imgId) ;   
		obj.outerHTML=obj.outerHTML;  
		
		$('#'+imgShow).attr("src", "");
	}
	

</script>
	<div class="body">
		<div class="inputBar">
			<h1><span class="icon">&nbsp;</span><#if teacherId??>编辑教师<#else>新增教师</#if></h1>
		</div>
		<div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
			<div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
				<ul></ul>
			</div>
		</div>		
		<form id="inputForm" class="validate" action="<#if teacherId??>${web_base}/go/teacher!edit.htm<#else>${web_base}/go/teacher!save.htm</#if>" method="post" enctype="multipart/form-data">
			<input type="hidden" name="teacherInfo.teacherId" value="${(teacherInfo.teacherId)!}"/>
			<table class="inputTable tabContent">
				<tr>
					<th>
						教师姓名：
					</th>
					<td>
						<input type="text" id="" name="teacherInfo.teacherName" class="formText required" value="${(teacherInfo.teacherName)!}" />
						<label id="labelUrl" class="requireField">*</label>
					</td>
				</tr>
				<tr>
					<th>
						手机号码：
					</th>
					<td>
						<input type="text" id="" name="teacherInfo.mobile" class="formText required" value="${(teacherInfo.mobile)!}" />
						<label id="labelUrl" class="requireField">*</label>
					</td>
				</tr>
				<tr>
					<th>
						教师头像：
					</th>
					<td>
					<div style="float:left">
    				<input type="file" id="header" name="header" value="添加图片" onclick="showDiv('header','imgdiv1','imgShow1')"/>
						<div id="imgdiv1">
							<img id="imgShow1" width="160" height="100"  src="${(web_base + (teacherInfo.headerPath))!}"/>
							<span class="spanLink" onclick="clearImg('imgdiv1','imgShow1')" title="删除">[删除]</span>
						</div>
					</div>
					</td>
				</tr>
				<tr>
					<th>
						教师简介：
					</th>
					<td>
						<textarea rows="8" cols="60" name="teacherInfo.introduction" class="formText {}" >${(teacherInfo.introduction)!}</textarea>
					</td>
				</tr>
			</table>
			<div class="buttonArea">
				<input type="submit" class="formButton" value="提  交" hidefocus="true" />&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回" hidefocus="true" />
			</div>
		</form>
	</div>
</body>
</@edit>